#
# Copyright 2009 Jeffrey Palm
#

require 'util'
require 'itunes'
require 'player'

# Maintains the state of the player internally and prints out what
# it's doing to the console.  The read_info method will randomly
# choose something form your itunes library.
class ConsolePlayer < Player

  attr_reader :library
  
  # PLAYING | PAUSED
  attr_reader :state

  attr_reader :track_id

  def initialize(itunes=nil)
    @library  = ITunesBasedLibrary.new itunes
    @state    = PLAYING
    @track_id = 818        # Hoofprints in the sand
  end

  def read_info(user)
    info = @library.find_info @track_id
    puts info
    info[ 'user'] = user
    info['state'] = @state
    info[ 'time'] = 5           # random
    info
  end

  def play_track(track_id)
    @track_id = track_id
    @state = PLAYING
  end

  def pause
    @state = PAUSED
  end

end
